package Demo3;

public class Computer {
    public void open(){
        System.out.println("开机");
    }
    public void close(){
        System.out.println("关机");
    }
    public void useDevice(USB usb){//只要实现了USB接口的都能传进来
        usb.openDevice();
        if (usb instanceof Mouse){
            Mouse mouse=(Mouse) usb;//发生向下转型
            mouse.click();
        }else if (usb instanceof KeyBoard){
            KeyBoard keyBoard=(KeyBoard) usb;
            keyBoard.inPut();
        }
    }
}
